/*
 * @Copyright: (C) 2019 Zhang Rida. All rights reserved.
 *
 * @Author: Zhang Rida
 * @Email: 215154317@qq.com
 * @FilePath: /WEILA_SDK_MODULE/include/wl_timer.h
 * @Date: 2021-02-18 15:07:07
 * @Description: timer for weila osal
 *
 * @LastEditors: Zhang Rida
 * @LastEditTime: 2022-03-29 15:23:08
 */

#ifndef _WL_TIMER_H
#define _WL_TIMER_H

#include "wl_types.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define WL_INVALID_TIMER 0

typedef wl_uint32 WL_TIMER;

typedef enum { NON_REPETITIVE, REPETITIVE } WL_TIMER_TYPE;

// 定时器的回调函数定义
typedef void (*wl_timer_callback)(WL_TIMER timer, void* context);

/**
 * @description: 启动定时器
 * @param interval 定时器响应间隔 单位毫秒
 * @param type 定时器类型
 * @param callback 定时器回调函数
 * @param context
 * @param taskid 定时器响应task
 * @param timer_name 定时器名称
 * @return 成功 定时器 失败 WL_INVALID_TIMER
 */
WL_TIMER
wl_timer_start(wl_uint32         interval,
               WL_TIMER_TYPE     type,
               wl_timer_callback callback,
               void*             context,
               wl_int32          taskid,
               wl_char*          timer_name);

/**
 * @description: 停止定时器
 * @param timer 定时器
 * @return 成功 0 失败 -1
 */
wl_int32 wl_timer_stop(WL_TIMER timer);

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _WL_TIMER_H */
